#!/usr/bin/env perl
use strict;

#above_average子程序，返回一组数中，大于其平均值的数
sub above_average {
	my $avg = &average(@_);
	my @result;
	for my $val ( @_ ) {
		if ( $val > $avg ) {
                    push( @result, $val );
                }
	}
	return @result;
}

#average子程序，计算一组数的平均值
sub average {
    my $total = 0;
    my $count = @_;
    for (@_) {
           $total += $_;
    }

    my $avg = $total / $count;
    return $avg;
}

#测试部分
my @fred = above_average(1..10);
print "\@fred is @fred\n";

my @barney = above_average(100, 1..10);
print "\@barney is @barney\n";
